package edu.esiag.isin.easyncloud.admin.business.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import edu.esiag.isin.easyncloud.admin.business.inf.ServiceManager;
import edu.esiag.isin.easyncloud.admin.repository.ServiceRepository;

@Service
public class DefaultServiceManager implements ServiceManager{

	@Autowired
	private ServiceRepository serviceRepository;

	@Override
	public edu.esiag.isin.easyncloud.admin.models.Service getService(String id) {
		
		return serviceRepository.selectOne(id);
	}

	@Override
	public List<edu.esiag.isin.easyncloud.admin.models.Service> getAllServices() {
		return serviceRepository.selectAll();
	}

	@Override
	public boolean runService(String id) {
		serviceRepository.updateState(id, true);
		return true;
	}

	@Override
	public boolean stopService(String id) {
		serviceRepository.updateState(id, false);
		return true;
	}
	
	
}
